<div id="topHead">
  <div class="lftArea"> </div>
  <?php if ($sf_user->isAuthenticated()) : ?>
  <div class="rhtArea">
    <div class="topNav">
      <div class="rhtNav2">
        <ul>
          <li class="welcome"><span class="blackFont">Welcome <b><?php echo $sf_user->getAttribute(Constants::SESSION_FIRST_NAME); ?></b>!</span></li>
          <li><a href="<?php echo url_for('@change_password'); ?>">Change Password</a></li>
          <li><a href="<?php echo url_for('@signout'); ?>">Logout</a></li>
        </ul>
      </div>
    </div>
  </div>
  <?php endif; ?>
</div>

<?php
function highlightTab($tab) {
  $route = sfContext::getInstance()->getRouting()->getCurrentInternalUri(true);
  $route = explode('_', substr($route, 1));
  $module = trim($route[0]);
  if ((is_array($tab) && in_array($module, $tab)) || $tab === $module) {
    echo ' class="top_menu_item_active"';
  }
}
?>
<div id="Nav">
  <!--navigation start-->
  <div class="menu">
    <ul class="pureCssMenu pureCssMenum" id="mainHolder">
      <?php if ($sf_user->isAuthenticated()) : ?>
      <li class="pureCssMenui">
        <a href="<?php echo url_for('@offer_add'); ?>"<?php highlightTab('offer'); ?>><span>Offer Management</span></a>
        <ul class="pureCssMenum">
          <li><a href="<?php echo url_for('@offer_add'); ?>">Add Offer</a></li>
          <li><a href="<?php echo url_for('@offer_list_current'); ?>">Active Offers</a></li>
          <li><a href="<?php echo url_for('@offer_list_expired'); ?>">Expired Offers</a></li>
          <li><a href="<?php echo url_for('@movie_add'); ?>">Add Movie</a></li>
          <li><a href="<?php echo url_for('@movie_list'); ?>">View Movies</a></li>
        </ul>
      </li>
      <?php if ($sf_user->hasCredential(Constants::USER_GROUP_SUPER_ADMIN)) : ?>
      <li class="pureCssMenui">
        <a href="<?php echo url_for('@merchant_add'); ?>"<?php highlightTab(array('merchant', 'user', 'cinema')); ?>><span>Merchant Management</span></a>
      </li>
      <?php endif; ?>
      <?php if ($sf_user->hasCredential(Constants::USER_GROUP_SUPER_ADMIN)) : ?>
      <li class="pureCssMenui">
        <a href="<?php echo url_for('@member_list'); ?>"<?php highlightTab('member'); ?>><span>Member Management</span></a>
      </li>
      <?php endif; ?>
      <?php if ($sf_user->hasCredential(Constants::USER_GROUP_SUPER_ADMIN) || $sf_user->hasCredential(Constants::USER_GROUP_MERCHANT_ADMIN)) : ?>
      <!--<li class="pureCssMenui">
        <a href="#"<?php highlightTab('accounts'); ?>><span>Accounts</span></a>
      </li>-->
      <?php endif; ?>
      <li class="pureCssMenui">
        <a href="<?php echo url_for('@about'); ?>"<?php highlightTab('about'); ?>><span>About</span></a>
      </li>
      <li class="pureCssMenui">
        <a href="<?php echo url_for('@contact'); ?>"<?php highlightTab('contact'); ?>><span>Contact</span></a>
      </li>
      <li class="pureCssMenui">
        <a href="<?php echo url_for('@help'); ?>"<?php highlightTab('help'); ?>><span>Help</span></a>
      </li>
      <?php endif; ?>
    </ul>
  </div>
  <!--navigation end-->
</div>